package 动态规划.dp声明正序And倒序;

import java.util.Scanner;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/6/15 9:47
 */
public class 奖励关新理解 {

    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {

        int k = sc.nextInt(), n = sc.nextInt();
        int[][] init = new int[n + 1][2];
        for (int i = 1; i <= n; i++) {
            init[i][0] = sc.nextInt();
            int in;
            while ((in = sc.nextInt()) != 0) {
                init[i][1] |= 1 << (in - 1);
            }
        }
        Double dp[][] = new Double[k + 1][1 << n];

        double ans = recursion(0,0,init,dp,k,n);
        System.out.printf("%6f",ans);
    }

    private static double recursion(int index, int state, int[][] init, Double[][] dp,int k,int n) {
        if(index == k){
            return 0.0;
        }
        if(dp[index][state] != null){
            return  dp[index][state];
        }
        double ans = 0;
        for(int i = 1;i <= n;i++){
            double temp;
            // 直接跳过当前 抛出的奖品 （无论，能不能 选）
            temp = recursion(index + 1,state,init,dp,k,n);
            //决策 约束！  满足前置条件
            if((state & init[i][1]) == init[i][1]){
                temp = Math.max(recursion(index + 1,state | (1 << i - 1),init,dp,k,n) + init[i][0],temp);
            }
            ans += temp;
        }
        return dp[index][state] = ans / n;
    }

}
